#include "stdafx.h"
#include "SpriteTime.h"
#include "SpriteStaticPart.h"

SpriteTime::SpriteTime(LPDIRECT3DTEXTURE9 tex, int nWidth,int nHeight,unsigned short nNumOfFrame,unsigned short nCol,int nLayer,bool bDrawOnView):
SpriteCombined(nLayer),m_dTime(0),m_nWidth(nWidth)
{
	int i=0;
	for (i=0;i<5;i++){
		SpriteStaticPart *p=new SpriteStaticPart(tex,nWidth,nHeight,nNumOfFrame,nCol,nLayer,bDrawOnView);
		if (p){
			p->m_vPosition.x=i*m_nWidth;
			AddSprite(p);
		}
	}
}

SpriteTime::~SpriteTime(void)
{

}

bool SpriteTime::Draw(DWORD dwCurrentTime)
{
	DWORD dmin=m_dTime/60;
	DWORD dsec=m_dTime%60;

	vector<BaseDispSprite*>::iterator it=m_listSprite.begin();
	dynamic_cast<SpriteStaticPart *>(*it++)->SetDrawingFrame(dmin/10+1);
	dynamic_cast<SpriteStaticPart *>(*it++)->SetDrawingFrame(dmin%10+1);
	dynamic_cast<SpriteStaticPart *>(*it++)->SetDrawingFrame(0);
	dynamic_cast<SpriteStaticPart *>(*it++)->SetDrawingFrame(dsec/10+1);
	dynamic_cast<SpriteStaticPart *>(*it++)->SetDrawingFrame(dsec%10+1);

	return SpriteCombined::Draw(dwCurrentTime);
}